﻿using System;

namespace Eventless
{
    internal class DisposeAction : IDisposable
    {
        private Action _dispose;

        public DisposeAction(Action action)
        {
            _dispose = action;
        }

        public void Dispose()
        {
            if (_dispose == null) return;
            var d = _dispose;
            _dispose = null;
            d();
        }
    }
}